<template>
	<!-- 进度条 -->
	<view class="outsidebox">
		<view class="u-progress" :style="{
			borderRadius: round ? '30rpx' : 0,
			height: height + 'rpx',
		}">
			<view :class="[
				type ? `u-type-${type}-bg` : '',
				striped ? 'u-striped' : '',
				striped && stripedActive ? 'u-striped-active' : ''
			]" class="u-active" :style="[progressStyle]">
				<slot v-if="$slots.default || $slots.$default" />
				
			</view>
		</view>
	</view>
	
</template>

<script>
	/**
	 * lineProgress 线型进度条
	 * @description 展示操作或任务的当前进度，比如上传文件，是一个线形的进度条。
	 * @tutorial https://www.uviewui.com/components/lineProgress.html
	 * @property {String Number} percent 进度条百分比值，为数值类型，0-100
	 * @property {Boolean} round 进度条两端是否为半圆（默认true）
	 * @property {String} type 如设置，active-color值将会失效
	 * @property {String} active-color 进度条激活部分的颜色（默认#19be6b）
	 * @property {String} inactive-color 进度条的底色（默认#ececec）
	 * @property {Boolean} show-percent 是否在进度条内部显示当前的百分比值数值（默认true）
	 * @property {String Number} height 进度条的高度，单位rpx（默认28）
	 * @property {Boolean} striped 是否显示进度条激活部分的条纹（默认false）
	 * @property {Boolean} striped-active 条纹是否具有动态效果（默认false）
	 * @example <u-line-progress :percent="70" :show-percent="true"></u-line-progress>
	 */
	export default {
		name: "Progress",
		props: {
			// 两端是否显示半圆形
			round: {
				type: Boolean,
				default: true
			},
			// 主题颜色
			type: {
				type: String,
				default: ''
			},
			// 激活部分的颜色
			activeColor: {
				type: String,
				default: '#19be6b'
			},
			inactiveColor: {
				type: String,
				default: '#ececec'
			},
			// 进度百分比，数值
			percent: {
				type: Number,
				default: 0
			},
			// 是否在进度条内部显示百分比的值
			showPercent: {
				type: Boolean,
				default: true
			},
			// 进度条的高度，单位rpx
			height: {
				type: [Number, String],
				default: 28
			},
			// 是否显示条纹
			striped: {
				type: Boolean,
				default: false
			},
			// 条纹是否显示活动状态
			stripedActive: {
				type: Boolean,
				default: false
			},
			allnum:{
				type: [Number, String],
				default: ''
			}
		},
		data() {
			return {
				
			}
		},
		computed: {
			progressStyle() {
				let style = {};
				style.width = (this.percent / 100) * 100 + '%';
				if(this.activeColor) style.backgroundColor = this.activeColor;
				return style;
			}
		},
		methods: {

		}
	}
</script>

<style lang="scss" scoped>
	@import "../../node_modules/uview-ui/libs/css/style.components.scss";

	.outsidebox {
		overflow: hidden;
		/* #ifndef APP-NVUE */
		display: inline-flex;
		/* #endif */
		align-items: center;
		width: 100%;
		background: linear-gradient(180deg, #E89E43 0%, #D37E2D 100%);
		box-shadow: inset 0px 1px 3px 0px rgba(241,201,153,1), inset 0px -1px 3px 0px rgba(167,82,23,1);
		border-radius: 11px;
		padding: 4px;
	}

	.u-progress {
		overflow: hidden;
		height: 15px;
		/* #ifndef APP-NVUE */
		display: inline-flex;
		/* #endif */
		align-items: center;
		width: 100%;
		background: #9E4309;
		box-shadow: inset 0px 1px 3px 0px rgba(132,43,0,1);
		border-radius: 8px;
		
	}

	.u-active {
		width: 0;
		height: 100%;
		align-items: center;
		@include vue-flex;
		justify-items: flex-end;
		justify-content: space-around;
		font-size: 20rpx;
		transition: all 0.4s ease;
		background: url('http://img.cpgm.cc/panda/static/challange/pro.png'), linear-gradient(180deg, #E4C60D 0%, #FFE079 27%, #F1650B 100%);
		background-size: auto 100%;
		border-radius: 7px;
		overflow: hidden;
	}

	.u-striped {
		background-size: 39px 39px;
	}

	.u-striped-active {
		animation: progress-stripes 2s linear infinite;
	}

	@keyframes progress-stripes {
		0% {
			background-position: 0 0;
		}

		100% {
			background-position: 39px 0;
		}
	}

	.white {
		position: absolute;
		left: 50%;
		transform: translateX(-50%);
		color: #fff !important;  
		font-size: 12px;
	}
</style>
